package com.example.inperson;

import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.content.Intent;

public class TasteProfile extends ActionBarActivity {
	boolean check1, check2, check3;
	String name;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_taste_profile);

		if (savedInstanceState == null) {
			getSupportFragmentManager().beginTransaction()
			.add(R.id.container, new PlaceholderFragment()).commit();
		}

		Intent intent = getIntent();

		if (intent.hasExtra("name"))
			name = intent.getStringExtra("name"); //if it's a string you stored.
		if (intent.hasExtra("check1"))
			check1 = intent.getBooleanExtra("check1", false);
		if (intent.hasExtra("check2"))
			check2 = intent.getBooleanExtra("check2", false);
		if (intent.hasExtra("check3"))
			check3 = intent.getBooleanExtra("check3", false);
	}

	// Called when the next button is clicked.
	public void nextScreen(View view) {
		Intent myIntent = new Intent(getBaseContext(), Loading.class);
		// myIntent.putExtra("key", value); //Optional parameters
		TasteProfile.this.startActivity(myIntent);

		//in here, should we "commit" the changes made to the user profile?
	}

	// Called when the back button is clicked.
	public void prevScreen(View view) {
		Intent myIntent = new Intent(getBaseContext(), ProfileScreen.class);
		myIntent.putExtra("name", name); //Optional parameters
		myIntent.putExtra("check1", check1);
		myIntent.putExtra("check2", check2);
		myIntent.putExtra("check3", check3);
		TasteProfile.this.startActivity(myIntent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.taste_profile, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	/**
	 * A placeholder fragment containing a simple view.
	 */
	public static class PlaceholderFragment extends Fragment {

		public PlaceholderFragment() {
		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			View rootView = inflater.inflate(R.layout.fragment_taste_profile,
					container, false);
			return rootView;
		}
	}

}
